package com.atwu.wl2022.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 评论实体
 * 对前端要展示的信息封装
 * @author wulejay
 */
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "comment")
public class Comment {

	@TableId(value="id",type= IdType.AUTO)
	private Integer id;

	/**
	 * 用户id
	 */
	@TableField(value = "user_id" )
	private Integer userId;

	/**
	 * 所属文章id
	 */
	@TableField(value = "article_id")
	private Integer articleId;

	@TableField(value = "content" )
	private String content;

	@TableField(value = "create_time",fill = FieldFill.INSERT)
	private Date createTime;

	/**
	 * 父id
	 */
	@TableField(value = "pid" )
	private Integer pid;

	/**
	 * 祖先id，最上层id
	 */
	@TableField(value = "origin_id" )
	private Integer originId;

//	拓展属性

	@TableField(value = "likes" )
	private Integer likes;

	/**
	 * 是否禁言，0为否，1为是
	 */
	@TableField(value = "is_delete" )
	private Integer isDelete;



	//回复评论
	/**
	 * 用户头像
	 */
	@TableField(exist = false)
	private String headImage;
	/**
	 * 用户名字
	 */
	@TableField(exist = false)
	private String nickName;
	/**
	 *  父用户名
	 */
	@TableField(exist = false)
	private String parentNickName;
	/**
	 * 父用户id
	 */
	@TableField(exist = false)
	private Integer parentUserId;

	/**
	 * 评论人身份
	 */
	@TableField(exist = false)
	private Integer reviewerIdentity;


	/**
	 * 子评论集合
	 */
	@TableField(exist = false)
	private List<Comment> replyComments = new ArrayList<>();


	public Comment(Integer userId, Integer articleId, String content) {
		this.userId = userId;
		this.articleId = articleId;
		this.content = content;
	}

	public Comment(Integer userId, Integer articleId, String content,Integer pid) {
		this.userId = userId;
		this.articleId = articleId;
		this.content = content;
		this.pid=pid;
	}
}
